﻿#pragma once;
#include "MyShape.h"

class MyRectangle : public MyShape
{
private:
	char* _stroke;
	char* _fill;
	float _strokeWidth;
	int _x;
	int _y;
	int _width;
	int _height;
public:
	MyRectangle(){};
	MyRectangle(char stroke[], char fill[], float strokeWidth, int x, int y, int width, int height) {
		_stroke = stroke;
		_fill = fill;
		_strokeWidth = strokeWidth;
		_x = x;
		_y = y;
		_width = width;
		_height = height;
	}
	void Draw() {
		this->getMyGraphic()->DrawRectangle(_stroke, _strokeWidth, _x, _y, _width, _height);
		//Chưa xử lý nếu không muốn tô
		if(_fill != NULL)
			this->getMyGraphic()->FillRectangle(_fill, _x, _y, _width, _height);
	}
	string ToString() {
		string s = "";		
		s += "<rect x='";		
		s += MyFunction::IntToString(this->_x);
		s += "' y='";
		s += MyFunction::IntToString(this->_y);
		s += "' width='";
		s += MyFunction::IntToString(this->_width);
		s += "' height='";
		s += MyFunction::IntToString(this->_height);
		s += "' stroke='rgb(";
		s += MyFunction::Char2String(this->_stroke[0]);
		s += ", ";
		s += MyFunction::Char2String(this->_stroke[1]);
		s += ", ";
		s += MyFunction::Char2String(this->_stroke[2]);
		s += ")' stroke-width='";
		s += MyFunction::FloatToString(this->_strokeWidth);
		if(this->_fill != NULL) {
			s += "' fill='rgb(";
			s += MyFunction::Char2String(this->_fill[0]);
			s += ", ";
			s += MyFunction::Char2String(this->_fill[1]);
			s += ", ";
			s += MyFunction::Char2String(this->_fill[2]);
			s += ")' />";
		}
		else {
			s += "' fill='none' />";
		}

		return s;
	}	
};
